#!/bin/bash

#info
ONOS_HOME=~/onos
cd $ONOS_HOME/
source tools/dev/bash_profile

echo "...waiting for onos to start..."
sleep 40s

#run onos-CLI

echo "...install onos-apps..."

$ONOS_HOME/tools/package/runtime/bin/onos-app localhost install $ONOS_HOME/bazel-out/k8-fastbuild/bin/apps/NDNandSINETandGEO/pipeconf/onos-apps-NDNandSINETandGEO-pipeconf-oar.oar

$ONOS_HOME/tools/package/runtime/bin/onos-app localhost install $ONOS_HOME/bazel-out/k8-fastbuild/bin/apps/NDNandSINETandGEO/NDN/onos-apps-NDNandSINETandGEO-NDN-oar.oar

$ONOS_HOME/tools/package/runtime/bin/onos-app localhost install $ONOS_HOME/apps/pinet-network-manage/target/PinetNetworkManage-1.0-SNAPSHOT.oar

$ONOS_HOME/tools/package/runtime/bin/onos-app localhost install $ONOS_HOME/apps/IPv4APP/target/IPv4App-1.0-SNAPSHOT.oar

onos localhost "app activate org.onosproject.drivers.bmv2;app activate org.onosproject.openflow"
onos localhost "app activate org.onosproject.NDNandSINETandGEO.pipeconf"
onos localhost "app activate org.onosproject.proxyarp"
onos localhost "app activate org.onosproject.NDNandSINETandGEO.NDN"
onos localhost "app activate bjtu.pinet.IPv4App"
onos localhost "app activate bjtu.pinet.PinetNetworkManage"

#;app activate org.onosproject.NDN.NDN

#new terminal for mininet

echo "...waiting for app installation..."
sleep 20s


echo "...start UI & new terminal for mininet"

coproc gnome-terminal --window -x bash -c "google-chrome http://127.0.0.1:8181/onos/ui/#/topo2;"

# gnome-terminal --window -x bash -c "bash ./run-mn.sh;exec bash;"
gnome-terminal --window -- "./run-mn.sh"






